<?php

namespace App\Http\Controllers\Api;

use App\Repositories\CategoryRepo;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Repositories\ProductRepo;
class ProductController extends ApiBaseController
{
    protected $productRepo;
    protected  $categoryRepo;
    public function _initialize()
    {
        $this->productRepo = new ProductRepo();
        $this->categoryRepo = new CategoryRepo();
    }
    public function info(Request $request)
    {
        $id = $request->id;
        if(!$id) {
            return $this->sucRes(5000,'商品不存在');
        }
        $product =  $this->productRepo->getOneProduct($id);
        $data['product'] =$product;
        return $this->sucRes(200,$data);
    }

    public function lists(Request $request)
    {
        $productRepo = new ProductRepo();
        $data['lists'] = $productRepo->getProductList(['is_able'=>1],10);
        return $this->sucRes(200,$data);
    }
}
